#include<iostream>
#include<string>
using namespace std;

void TestStringMemberFunc()
{
	string st1;
	string st2("hello string");
	string st3(st2);
	st1 = st2;
	cout << st1 << endl;
	cout << st2 << endl;
	cout << st3 << endl;
}

void TestStringIterator()
{
	string st1("hello string");

	for (size_t i = 0; i < st1.size(); i++)
	{
		cout << st1[i] << " ";
	}
	cout << endl;

	string::iterator it = st1.begin();
	while (it != st1.end())
	{
		(*it)++;
		cout << (*it) << " ";
		it++;
	}
	cout << endl;

	string::reverse_iterator rit = st1.rbegin();
	while (rit != st1.rend())
	{
		cout << (*rit) << " ";
		rit++;
	}
	cout << endl;


	for (auto ch : st1)
	{
		cout << ch << " " ;
	}
	cout << endl;

	for (auto& ch : st1)
	{
		ch++;
		cout << ch << " ";
	}
	cout << endl;
}

void TestStringCapacity()
{
	string st;
	string st1("123456789123456");

	cout << "size():" << st1.size() << endl;
	cout << "size():" << st.size() << endl;

	cout << "length():" << st1.length() << endl;
	cout << "length():" << st.length() << endl;

	cout << "capacity():" << st1.capacity() << endl;
	cout << "capacity():" << st.capacity() << endl;

	cout << "capacity= " << st.capacity();
	st.reserve(20);
	cout << " reserve()-> " << st.capacity() << endl;

	cout << "capacity= " << st.capacity();
	st.reserve(40);
	cout << " reserve()-> " << st.capacity() << endl;

	cout << "capacity= " << st.capacity();
	st.reserve(60);
	cout << " reserve()-> " << st.capacity() << endl;

	cout << "capacity= " << st.capacity();
	st.reserve(100);
	cout << " reserve()-> " << st.capacity() << endl;


	cout << "st == " << st1 << endl;
	st1.clear();
	cout << " clear()-> st == " << st1 << endl;
}

//int main()
//{
//	//TestStringMemberFunc();
//	//TestStringIterator();
//	TestStringCapacity();
//	return 0;
//}